package com.summer.hundred;

import java.util.HashSet;
import java.util.Set;

public class ques3 {
    static int max =0;

    public static void main(String[] args) {

        String s = "qwertyuiopasdfghjklzxcvbnm";
        System.out.println(lengthOfLongestSubstring(s));
    }

    public static int lengthOfLongestSubstring(String s) {
         int pre= 0;
         int cur = 0;
            if (s.length() > 0) {
                Set<Character> set = new HashSet<>();
                for (int i = 0; i < s.length(); i++) {

                    pre = set.size();
                    set.add(s.charAt(i));
                    cur = set.size();
                    if (pre == cur) break;
                }
                max = max>cur?max:cur;
                s = s.substring(1);
                lengthOfLongestSubstring(s);
            }

      return  max;
    }
}